﻿using System;
using System.IO;
using System.Text;
namespace GestorDeFlotasDesktop
{

    public class Logger
    {
        private static string nameFile = "GestorDeFlotas.log";
        public enum Type { TYPE_DEBUG, TYPE_INFO, TYPE_WARN, TYPE_ERROR };
       
        public static string NameFile 
        {
            get { return nameFile; }
            set { nameFile = value; }
        }

        public Logger()
        {
        }
        public static void loggear(Type type, String msg)
        {
            StringBuilder stbuilder = new StringBuilder();
            DateTime dt = new DateTime();

            stbuilder.AppendFormat(MSG_LOG, DEBUG, dt, msg);
            StreamWriter sWriter = new StreamWriter(NameFile, true);
            sWriter.WriteLine(stbuilder.ToString());
            sWriter.Close();
        }
        private const string DEBUG = "DEBUG";
        private const string INFO = "INFO";
        private const string ERROR = "ERROR";
        private const string WARN = "WARN";
        private const string MSG_LOG = "{0} {1:d/M/yyyy HH:mm:ss} : {2}.";
    }
}